package com.wink.admin.config;

import com.github.pagehelper.PageInterceptor;
import com.wink.admin.common.MybatisPlusAutoFillHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * MybatisPlus配置
 *
 * @author donaldhan
 */
@Configuration
public class MybatisPlusConfig {


    /**
     * SQL语句输出
     * pro 环境不打印sql
     */
    @Bean
    @Profile({"dev", "test"})
    public ExtPerformanceInterceptor performanceInterceptor() {
        return new ExtPerformanceInterceptor(2000);
    }

    // @Bean
    // public MasterSlaveAutoRoutingPlugin masterSlaveAutoRoutingPlugin(){
    //     return new MasterSlaveAutoRoutingPlugin();
    // }

    /**
     * pagehelper的分页插件
     */
    @Bean
    public PageInterceptor pageInterceptor() {
        return new PageInterceptor();
    }


    @Bean
    public MybatisPlusAutoFillHandler getMybatisPlusAutoFillHandler() {
        return new MybatisPlusAutoFillHandler();
    }
}
